package org.coopac.dao.impl;

import java.util.List;

import org.coopac.dao.IUbigeoDAO;
import org.coopac.model.CoopacUbigeo;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("UbigeoDAO")
public class UbigeoDAO extends BaseDaoImpl<CoopacUbigeo> implements IUbigeoDAO {
	
	@Autowired
	SessionFactory sessionFactory;
	
	
	protected SessionFactory getSessionFactory() {
		return sessionFactory;
	}


	@Override
	public List<CoopacUbigeo> listar() {
		return super.listar(CoopacUbigeo.class);
	}

	@Override
	public void save(CoopacUbigeo ubigeo) {
		super.save(ubigeo);
	}

	@Override
	public void update(CoopacUbigeo ubigeo) {
		super.update(ubigeo);
	}

	@Override
	public void delete(CoopacUbigeo ubigeo) {
		super.delete(ubigeo);
	}

	@Override
	public CoopacUbigeo getById(int id) {
		return (CoopacUbigeo) super.getById(CoopacUbigeo.class, id);
	}


	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<CoopacUbigeo> listById(int id) {
		List list = getSessionFactory().getCurrentSession().
		createQuery("from CoopacUbigeo where floor(idUbigeo/100)="+id).list();
		return list;
	}
	
	

}
